package com.controller;

import com.entity.Book;
import com.service.BookService;
import com.until.OSSUtil;
import com.until.Result;
import com.vo.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @ fileName:BookController
 * @ description:
 * @ author:dzh
 * @ createTime:2022/4/29 17:08
 * @ version:1.0.0
 */
@RestController
@RequestMapping("book")
public class BookController extends BaseController{
    @Resource
    private BookService service;
    @PostMapping("list")
    public Result list(@RequestBody Page<Book> page){
        return success(service.listByParam(page));
    }
    @PostMapping("insert")
    public Result insert(@RequestBody Book book){
        return success(service.insert(book));
    }
    @PostMapping("update")
    public Result update(@RequestBody Book book){
        return success(service.update(book));
    }
    @DeleteMapping("del")
    public Result delById(Integer bookId){
        return success(service.delById(bookId));
    }

    /**
     *人员头像上传
     * @param bookImg
     * @return */
    @RequestMapping("uploadUserHeadPic")
    public Result uploadUserHeadPic(@RequestParam MultipartFile bookImg) {
        return success(OSSUtil.uploadFile("img/book",bookImg));
    }
}
